import torch
import torch.nn as nn

class RNN(nn.Module):
    def __init__(self,input_size,hidden_size,output_size):
        super(RNN,self).__init__()
        self.hidden_size = hidden_size
        self.u = nn.Linear(input_size,hidden_size)
        self.w = nn.Linear(hidden_size,hidden_size)
        self.v = nn.Linear(hidden_size,output_size)

        self.tanh = nn.Tanh()
        self.softmax = nn.LogSoftmax(dim =1)

    def forward(self,inputs,hidden):
        u_x = self.u(inputs)
        hidden = self.w(hidden)
        hidden = self.tanh(hidden+u_x)
        output = self.softmax(self.v(hidden))
        return output,hidden

    def initHidden(self):
        return torch.zeros(1,self.hidden_size)
    